<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>版本管理</title>
    <link rel="stylesheet" href="../../libs/layui/css/layui.css">
    <link rel="stylesheet" href="../static/css/main.css">
</head>
<body>
    <div class="page-container">
        <div class="page-header">
            <h2 class="page-title">版本管理</h2>
        </div>
        
        <!-- 工具栏 -->
        <div class="table-toolbar">
            <div class="layui-btn-group">
                <button class="layui-btn layui-btn-sm" id="add-version"><i class="layui-icon">&#xe654;</i> 新增版本</button>
                <button class="layui-btn layui-btn-primary layui-btn-sm" id="export-versions"><i class="layui-icon">&#xe67d;</i> 导出</button>
                <button class="layui-btn layui-btn-primary layui-btn-sm" id="import-versions"><i class="layui-icon">&#xe67c;</i> 导入</button>
            </div>
            
            <!-- 筛选条件 -->
            <div class="layui-form layui-inline">
                <div class="layui-input-inline" style="width: 150px;">
                    <select name="application" lay-filter="application" id="application-select">
                        <option value="">全部应用</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width: 150px;">
                    <select name="status" lay-filter="status">
                        <option value="">全部状态</option>
                        <option value="开发中">开发中</option>
                        <option value="测试中">测试中</option>
                        <option value="已发布">已发布</option>
                        <option value="已废弃">已废弃</option>
                    </select>
                </div>
                <div class="layui-input-inline" style="width: 200px;">
                    <input type="text" name="search" placeholder="搜索版本号" autocomplete="off" class="layui-input">
                </div>
                <button class="layui-btn layui-btn-primary layui-btn-sm" id="search-btn"><i class="layui-icon">&#xe615;</i> 搜索</button>
            </div>
        </div>
        
        <!-- 版本列表 -->
        <table id="version-table" lay-filter="version-table"></table>
        
        <!-- 表格操作按钮模板 -->
        <script type="text/html" id="table-operation">
            <a class="layui-btn layui-btn-xs layui-btn-sm" lay-event="edit">编辑</a>
            <a class="layui-btn layui-btn-normal layui-btn-xs layui-btn-sm" lay-event="features">功能</a>
            <a class="layui-btn layui-btn-danger layui-btn-xs layui-btn-sm" lay-event="del">删除</a>
        </script>
        
        <!-- 状态模板 -->
        <script type="text/html" id="statusTpl">
            {{#  if(d.status === '开发中'){ }}
            <span class="layui-badge layui-bg-orange">{{ d.status }}</span>
            {{#  } else if(d.status === '测试中'){ }}
            <span class="layui-badge layui-bg-blue">{{ d.status }}</span>
            {{#  } else if(d.status === '已发布'){ }}
            <span class="layui-badge layui-bg-green">{{ d.status }}</span>
            {{#  } else if(d.status === '已废弃'){ }}
            <span class="layui-badge layui-bg-gray">{{ d.status }}</span>
            {{#  } }}
        </script>
    </div>
    
    <!-- 新增/编辑版本表单 -->
    <div id="version-form" style="display: none; padding: 20px;">
        <form class="layui-form" lay-filter="version-form">
            <div class="layui-form-item">
                <label class="layui-form-label">版本号</label>
                <div class="layui-input-block">
                    <input type="text" name="versionNumber" required lay-verify="required" placeholder="请输入版本号(如v1.0.0)" autocomplete="off" class="layui-input">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">所属应用</label>
                <div class="layui-input-block">
                    <select name="applicationId" lay-verify="required" id="form-application-select">
                        <option value="">请选择应用</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item layui-form-text">
                <label class="layui-form-label">描述</label>
                <div class="layui-input-block">
                    <textarea name="description" placeholder="请输入版本描述" class="layui-textarea"></textarea>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态</label>
                <div class="layui-input-block">
                    <select name="status" lay-verify="required">
                        <option value="开发中">开发中</option>
                        <option value="测试中">测试中</option>
                        <option value="已发布">已发布</option>
                        <option value="已废弃">已废弃</option>
                    </select>
                </div>
            </div>
            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-sm" lay-submit lay-filter="save-version">保存</button>
                    <button type="reset" class="layui-btn layui-btn-primary layui-btn-sm">重置</button>
                </div>
            </div>
            <input type="hidden" name="id">
        </form>
    </div>
    
    <script src="../../libs/layui/layui.js"></script>
    <script src="../static/js/versions.js"></script>
    <script>
    layui.use(['table', 'form', 'layer', 'versions'], function(){
        var versions = layui.versions;
        versions.init();
    });
    </script>
</body>
</html>